/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 项目相关接口模块
 * +----------------------------------------------------------------------
 */
layui.define(['jquery', 'configure', 'configureCom'], function (exports) {
    var configure = layui.configure;
    var configureCom = layui.configureCom;
    var project = {
        param: {
            id: 0,
            data: {}
        },
        create: function () { // 创建项目
            return new Promise(function (resolve, reject) {
                var json = project.param.data;
                configureCom.postAjax(configure.UNIT_PROJECT_CREATE_HTTP, JSON.stringify(json)).then(function (data) {
                    resolve({code:1,msg:'登记成功',result:''});
                });
            });
        },
        edit: function () { //修改项目
            return new Promise(function (resolve, reject) {
                var json = project.param.data;
                configureCom.putAjax(configure.UNIT_PROJECT_CREATE_HTTP + project.param.id, JSON.stringify(json)).then(function (data) {
                    resolve({code:1,msg:'修改成功',result:''});
                });
            });
        },
        get: function () { //查看项目
            return new Promise(function (resolve, reject){
                configureCom.getAjax(configure.UNIT_PROJECT_CREATE_HTTP + project.param.id).then(function (data) {
                    resolve({code:1,msg:'',result:data.result});
                });
            });
        },
        getCreatorUnit:function(){
            return new Promise(function (resolve, reject){
                configureCom.getAjax(configure.UNIT_PROJECT_CREATOR_NAME_HTTP).then(function (data) {
                    resolve({code:1,msg:'', result:data.result});
                });
            });
        }
    };
    exports('project', project);
});